package com.java1234.rocketmq;

import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * 消息消费者

 我们可以通过 @RocketMQMessageListener 的 messageModel 属性值来设置，
 MessageModel.BROADCASTING 是广播模式， MessageModel.CLUSTERING 是默认集群负载均衡模式；

 lsof -i :6379

 idea 开启 allow parallel run

 */
@RocketMQMessageListener(topic = "java1234-rocketmq",consumerGroup = "${rocketmq.consumer.group}",messageModel= MessageModel.BROADCASTING)
@Component("consumerService")
public class ConsumerService implements RocketMQListener<String> {

    @Override
    public void onMessage(String message) {
        System.out.println("收到消息内容："+message);
    }
}
